/**
 * class to display reports including generation of simulation links
 * The class will also be used for formatting of different report results:
 * - show resources in red if storage capacity is exceeded
 * - show resources in yellow if storage capacity is at 90% or above
 * - add additional text information how many resources would be left if fleet cannot lift all resources
 * - indicate very few deuterium on moons as this could mean the player is unable to lift the fleet
 * - show irak range if information are available
 * - show phalanx range if information are available
 */
galaxytool = window.galaxytool || {};
galaxytool.report_display = galaxytool.report_display || {};

galaxytool.report_display = {
	report_dialog_close_connector : null,
	report_inline : false,
	GalaxytoolReportTooltipMouseOver: false,
	display : function(resources_on_text, planetname, report_coordinates, playername, report_when, report_inserted_text, username, reportInfo, is_moon, link_to_archive, archive_text, total_res_text) {
		if (link_to_archive != true && link_to_archive != false) return;
	    var content = '<div align="center">';
	    
	    content += '<table cellpadding="1" cellspacing="0" border="0" style="width:700px;">';
	    content += '<tr class="header"><td colspan="4">';
	    content += resources_on_text;
	    if (planetname != "") content += ' '+planetname;
	    
	    // http://galaxytool/secret/galaxyview.php?gala=1&system=193
	    var coordinates = report_coordinates.split(":");
	    var url = "galaxyview.php?gala="+coordinates[0]+"&system="+coordinates[1];
	    
	    content += ' <a href="'+url+'">['+report_coordinates+']</a> ';
	    if (playername != "") content += playername+' ';
	    content += report_when+' '+reportInfo["scantime"][0];
	    
	    if (galaxytool.report_display.report_inline == false) {
	    	content += " ";
	    	content += '<a href="report.php?coordinates='+report_coordinates+'&moon='+is_moon+'" target="_blank" style="float:right">';
	    	content += '<img src="../images/new_tab.png" border="0" alt="'+galaxytool_open_in_new_window_text+'" title="'+galaxytool_open_in_new_window_text+'"></a></img>';
	    }
	    
	    content += '</td></tr>'; 
	    
	    // variables must be defined via php at generated source code 
	    var speedsim = this.start_speedsim_link(galaxytool_def_to_debris, galaxytool_debris_rate, galaxytool_techs, galaxytool_language);
	    var dragosim = this.start_dragosim_link(galaxytool_def_to_debris, galaxytool_debris_rate, galaxytool_techs, galaxytool_language);
	    
		speedsim = this.update_speedsim_link(speedsim, "coordinates", report_coordinates);
		dragosim = this.update_dragosim_link(dragosim, "coordinates", report_coordinates, false, 0);
	    
	    var i=0;
	    var open = false;
	    var cargo = 0;
	    var resources = 0;
	    for (var key in reportInfo) {

	    	if (key == "id" || 
	    		key == "msg_id" || 
	    		key == "res_sum" || 
	    		key == "fleet_sum" || 
	    		key == "def_sum" || 
	    		key == "scantime" || 
	    		key == "planetname" || 
	    		key == "details" ||
	    		key == "username") { continue; }
	    	
	    	if (key == "h1" || 
	    		key == "h2" || 
	    		key == "h3" || 
	    		key == "h4" || 
	    		key == "h5") {
	    		if (open == true) {
	        		content += '<td colspan="2">&nbsp;</td>';
	        		content += '</tr>';
	    		}
	    		var class_name = (reportInfo[key][0] == "ok") ? "truespio" : "falsespio"; 
	    		content += '<tr class="header '+class_name+'"><td colspan="4">'+reportInfo[key][1]+'</td></tr>';
	    		i=0;
	    		continue;
	    	}
	    	
	    	if (key == "kt" ||
	    		key == "gt" ||
	    		key == "lj" ||
	    		key == "sj" ||
	    		key == "krz" ||
	    		key == "ss" ||
	    		key == "kolo" ||
	    		key == "rec" ||
	    		key == "bomb" ||
	    		key == "zerri" ||
	    		key == "ds" ||
	    		key == "skrz") {
	    		// fleet - except sats and spio
	    		
	    		if (reportInfo[key][0] > 0) cargo += this.get_cargo_capacity(key) * reportInfo[key][0];
	    	}
	    	
			if (key == "metal" || key == "crystal" || key == "deuterium") {
				resources += parseInt(reportInfo[key][0]);
			}

	    	var unformatted = reportInfo[key][0];
			if (!isNaN(parseFloat(reportInfo[key][0])) && isFinite(reportInfo[key][0])) {
				// value is numeric
				// don't show 0 values, except for metal/crystal/deuterium/energy
				if (reportInfo[key][0] == 0 && key != "metal" 
					&& key != "crystal" && key != "deuterium"
					&& key != "energy")
					continue;
				
				// update links
				speedsim = this.update_speedsim_link(speedsim, key, reportInfo[key][0]);
				dragosim = this.update_dragosim_link(dragosim, key, reportInfo[key][0], true, 0);
				
				// do not format value here
			}
			
			var css_class = "";
			if (key == "metal" || key == "crystal" || key == "deuterium") {
				var storage_key = null;
				switch(key) {
				case "metal":     storage_key = "mesp";   break;
				case "crystal":   storage_key = "krissp"; break;
				case "deuterium": storage_key = "deutsp"; break;
				}
				var storage = 0;
				try {
					storage = reportInfo[storage_key][0];
				} catch(not_there) { alert(not_there); }
				if (reportInfo["h4"][0] == "ok" && !is_moon) {
					var capacity = this.get_storage_capacity(storage);
					if (capacity <= unformatted) {
						css_class = "class=\"traffic_light_red\"";
					} else if (capacity * 0.9 <=  unformatted) {
						css_class = "class=\"traffic_light_yellow\"";
					}
				}
			}
			    	
	    	if (i%2 == 0) {
	    		open = true;
	    		content += '<tr>';
	    		content += '<td style="padding-left:20px;">'+reportInfo[key][1]+
	    		           '</td><td style="padding-left:10px; padding-right:20px;" '+css_class+'>'+
	    		           NumberFormat(reportInfo[key][0])+'</td>';
	    	} else {
	    		open = false;
	    		content += '<td style="padding-left:20px;">'+reportInfo[key][1]+
	    		           '</td><td style="padding-left:10px; padding-right:20px;" '+css_class+'>'+
	    		           NumberFormat(reportInfo[key][0])+'</td>';
	    		content += '</tr>';
	    	}
	    	i++;
	    }
		if (open == true) {
			content += '<td colspan="2">&nbsp;</td>';
			content += '</tr>';
		}
		if (username != "" && username !== null) {
			content += '<tr class="header"><td colspan="4">'+report_inserted_text+' '+username+'</td></tr>';
		}
		
		// speedsim and dragosim links
		content += '<tr class="header"><td colspan="2"><a target="speedsim" href="'+speedsim+'">'+galaxytool_speedsim_text+'</a></td>';
		content += '<td colspan="2"><a target="dragosim" href="'+dragosim+'">'+galaxytool_dragosim_text+'</a></tr>';
		
		content += '<tr><td colspan="2" style="padding-left:20px;">'+total_res_text+'</td>';
		content += '<td style="padding-left:20px;" colspan="2">'+NumberFormat(resources)+'</tr>';
		
		if (reportInfo["h2"][0] == "ok") {
			// fleet specific information
			var css_class = (cargo < reportInfo["res_sum"][0]) ? "class=\"traffic_light_red\"" : ""; 
				
			content += '<tr><td colspan="2" style="padding-left:20px;">'+galaxytool_cargo_capacity_text+'</td>';
			content += '<td style="padding-left:20px;" colspan="2" '+css_class+'>'+NumberFormat(cargo)+'</tr>';
		}
		if (reportInfo["h4"][0] == "ok") {
			// building specific information
			// show phalanx range
			if (is_moon == true && reportInfo["sensor"][0] > 0) {
				content += '<tr><td colspan="2" style="padding-left:20px;">'+galaxytool_phalanx_text+'</td>';
				var min_range = parseInt(coordinates[1]) - (Math.pow(reportInfo["sensor"][0], 2) - 1);
				if (min_range < 0) min_range = 1;
				var max_range = parseInt(coordinates[1]) + (Math.pow(reportInfo["sensor"][0], 2) - 1);
				//TODO: some universes don't have 499 systems, but less!
				if (max_range > 499) max_range = 499;
				
				var url1 = "galaxyview.php?gala="+coordinates[0]+"&system="+min_range;
				var url2 = "galaxyview.php?gala="+coordinates[0]+"&system="+max_range;
				content += '<td style="padding-left:20px;" colspan="2"><a href="'+url1+'">'+coordinates[0]+':'+min_range+'</a>';
				content += ' - <a href="'+url2+'">'+coordinates[0]+':'+max_range+'</a></tr>';
			}
		}
		
		if (reportInfo["h5"][0] == "ok") {
			// tech specific information
			// show irak range
			if (reportInfo["impulse"][0] > 0 && is_moon == false && reportInfo["raksilo"][0] > 3) {
				content += '<tr><td colspan="2" style="padding-left:20px;">'+galaxytool_irak_text+'</td>';
				var min_range = parseInt(coordinates[1]) - ((reportInfo["impulse"][0] * 5) - 1);
				if (min_range < 0) min_range = 1;
				var max_range = parseInt(coordinates[1]) + ((reportInfo["impulse"][0] * 5) - 1);
				//TODO: some universes don't have 499 systems, but less!
				if (max_range > 499) max_range = 499;
				
				var url1 = "galaxyview.php?gala="+coordinates[0]+"&system="+min_range;
				var url2 = "galaxyview.php?gala="+coordinates[0]+"&system="+max_range;
				content += '<td style="padding-left:20px;" colspan="2"><a href="'+url1+'">'+coordinates[0]+':'+min_range+'</a>';
				content += ' - <a href="'+url2+'">'+coordinates[0]+':'+max_range+'</a></tr>';
			}
		}
		
		if (link_to_archive) {
			content += '<tr class="header"><td colspan="4"><a href="report_archive.php?coordinates='+report_coordinates+'&moon='+is_moon+'">'+archive_text+'</a></td></tr>';
		}
		
	    content += '</table></div>';
	    
	    return content;
	},
	
	addReportClickAndCloseListener: function() {
		if (this.report_dialog_close_connector == null) {
			var dojo_node = dojo.byId("ReportDialog_underlay");
			this.report_dialog_close_connector = dojo.connect(dojo_node, 'onclick', null, this.hideReport);
		}
	},
	
	hideReport: function(e) {
		dijit.byId("ReportDialog").hide();
		
		dojo.disconnect(this.report_dialog_close_connector);
		this.report_dialog_close_connector = null;
	},

	/*
	 * Tech have to look like this:
	 * { 
	 * vbt : 10,
	 * impulse : 10,
	 * hra : 10,
	 * waffentech : 10,
	 * schildtech : 10,
	 * rpz : 10
	 * } // all techs mus be provided
	 * 
	 * language must be the same as in languages.php
	 */
	start_speedsim_link : function(def_to_debris, debris_rate, techs, language) {
		var link = "http://websim.speedsim.net/?";

		// def to debris
		if (def_to_debris == true) {
			link += "def_to_df=1&amp;";
		} else {
			link += "def_to_df=0&amp;";
		}

		// debris ratio
		link += "perc-df="+debris_rate+"&amp;";
	
		// techs - if provided
		if (typeof(techs) == "object") {
			if (techs['vbt'] > 0) {
				link += "engine0_0="+techs['vbt']+"&amp;";
			}
			if (techs['impulse'] > 0) {
				link += "engine0_1="+techs['impulse']+"&amp;";
			}
			if (techs['hra'] > 0) {
				link += "engine0_2="+techs['hra']+"&amp;";
			}
			if (techs['waffentech'] > 0) {
				link += "tech_a0_0="+techs['waffentech']+"&amp;";
			}
			if (techs['schildtech'] > 0) {
				link += "tech_a0_1="+techs['schildtech']+"&amp;";
			}
			if (techs['rpz'] > 0) {
				link += "tech_a0_2="+techs['rpz']+"&amp;";
			}
		}
		
		switch (language) {
			case "german" :
				link += "lang=de&amp;";
				break;
			case "polish" :
				link += "lang=pl&amp;";
				break;
			case "english" :
				link += "lang=en&amp;";
				break;
			case "spanish" :
				link += "lang=sp&amp;";
				break;
			case "dutch" :
				link += "lang=nl&amp;";
				break;
			case "balkan" :
				link += "lang=ba&amp;";
				break;
			case "french" :
				link += "lang=fr&amp;";
				break;
			case "portugues" :
				link += "lang=pt&amp;";
				break;
			case "italian" :
				link += "lang=it&amp;";
				break;
			case "turkish" :
				// nothing yet
				break;
			case "danish" :
				link += "lang=dk&amp;";
				break;
			case "brazilian" :
				link += "lang=pt&amp;"; // no brazil yet, but pt is better than german
				break;
			case "russian" :
				link += "lang=ru&amp;";
				break;
			case "swedish" :
				link += "lang=sv&amp;";
				break;
			case "greek" :
				link += "lang=gr&amp;";
				break;
			case "romanian" :
				link += "lang=ro&amp;";
				break;
			case "hungarian" :
				link += "lang=hu&amp;";
				break;
			case "czech" :
				link += "lang=cz&amp;";
				break;
			case "korean" :
				link += "lang=kr&amp;";
				break;
			case "norwegian" :
				link += "lang=no&amp;";
				break;
			case "taiwan" :
				link += "lang=tw&amp;";
				break;
			case "japan" :
				link += "lang=ja&amp;";
				break;
			case "chinese" :
				link += "lang=cn&amp;";
				break;
			case "bulgarian" :
				link += "lang=bg&amp;";
				break;
			case "lithuanian" :
				link += "lang=lt&amp;";
				break;
			case "latvian" :
				link += "lang=lv&amp;";
				break;
			case "finnish" :
				link += "lang=fi&amp;";
				break;
			case "slovak" :
				link += "lang=sk&amp;";
				break;
			case "croatian" :
				link += "lang=ba&amp;";  //seems to be equal to balkan
				break;
			case "serbian" :
				// nothing yet
				break;
			case "slovenian" :
				link += "lang=si&amp;";
				break;
			default:
				link += "lang=en&amp;";
				break;
		}
		
		return link;
	},
	
	update_speedsim_link : function(link, key, value ) {
		if (link == "") {
			console.log("invalid method call - empty link provided");
			return false;
		}
		//?ship_d0_3_b=4&tech_a0_0=10&tech_d0_1=12&engine_0=10&ship_d0_18_b=1&engine0_0=10&enemy_metal=10.000
		if (value > 0 || key == "coordinates" || key == "enemy_name") {
			switch (key) {
				case "coordinates": link += "enemy_pos="+value+"&amp;"; break;
				case "enemy_name":  link += "enemy_name="+value+"&amp;"; break;

				case "metal":      link += "enemy_metal="+value+"&amp;"; break;
				case "crystal":    link += "enemy_crystal="+value+"&amp;"; break;
				case "deuterium":  link += "enemy_deut="+value+"&amp;"; break;

				case "kt":         link += "ship_d0_0_b="+value+"&amp;"; break;
				case "gt":         link += "ship_d0_1_b="+value+"&amp;"; break;
				case "lj":         link += "ship_d0_2_b="+value+"&amp;"; break;
				case "sj":         link += "ship_d0_3_b="+value+"&amp;"; break;
				case "krz":        link += "ship_d0_4_b="+value+"&amp;"; break;
				case "ss":         link += "ship_d0_5_b="+value+"&amp;"; break;
				case "kolo":       link += "ship_d0_6_b="+value+"&amp;"; break;
				case "rec":        link += "ship_d0_7_b="+value+"&amp;"; break;
				case "spio":       link += "ship_d0_8_b="+value+"&amp;"; break;
				case "bomb":       link += "ship_d0_9_b="+value+"&amp;"; break;
				case "sat":        link += "ship_d0_10_b="+value+"&amp;"; break;
				case "zerri":      link += "ship_d0_11_b="+value+"&amp;"; break;
				case "ds": 		   link += "ship_d0_12_b="+value+"&amp;"; break;
				case "skrz": 	   link += "ship_d0_13_b="+value+"&amp;"; break;

				case "rak": 	   link += "ship_d0_14_b="+value+"&amp;"; break;
				case "ll": 		   link += "ship_d0_15_b="+value+"&amp;"; break;
				case "sl": 		   link += "ship_d0_16_b="+value+"&amp;"; break;
				case "gauss": 	   link += "ship_d0_17_b="+value+"&amp;"; break;
				case "ion": 	   link += "ship_d0_18_b="+value+"&amp;"; break;
				case "plasma": 	   link += "ship_d0_19_b="+value+"&amp;"; break;
				case "ksk": 	   link += "ship_d0_20_b="+value+"&amp;"; break;
				case "gsk": 	   link += "ship_d0_21_b="+value+"&amp;"; break;

				case "waffentech": link += "tech_d0_0="+value+"&amp;"; break;
				case "schildtech": link += "tech_d0_1="+value+"&amp;"; break;
				case "rpz": 	   link += "tech_d0_2="+value+"&amp;"; break;

				case "arak":       link += "abm_b="+value+"&amp;"; break;
				case "irak":       link += "ipm_b="+value+"&amp;"; break;

			}


		}
		return link;
	},
	
	/*
	 * Tech have to look like this:
	 * { 
	 * vbt : 10,
	 * impulse : 10,
	 * hra : 10,
	 * waffentech : 10,
	 * schildtech : 10,
	 * rpz : 10
	 * } // all techs mus be provided
	 * 
	 * language must be the same as in languages.php
	 */
	start_dragosim_link : function(def_to_debris, debris_rate, techs, language) {
		// http://drago-sim.com/index.php?lang=german&numunits[0][0][k_t]=10&numunits[0][1][k_t]=20&num[0]=2 -> two attacker fleets num[0] = number of attacker
		var link = "http://drago-sim.com/?referrer=galaxytool&amp;";

		// debris ratio needs to be between 0 and 1 at dragosim
		link += "debris_ratio="+(debris_rate / 100)+"&amp;";

		if (def_to_debris == true) {
			link += "def_tf=0&amp;"; // dragosim wants 0 to set the checkbox as of now
		}

		// techs - if provided
		if (typeof(techs) == "object") {
			if (techs['waffentech'] > 0) {
				link += "techs[0][0][w_t]="+techs['waffentech']+"&amp;";
			}
			if (techs['schildtech'] > 0) {
				link += "techs[0][0][s_t]="+techs['schildtech']+"&amp;";
			}
			if (techs['rpz'] > 0) {
				link += "techs[0][0][r_p]="+techs['rpz']+"&amp;";
			}
		}		
		
		switch (language) {
			case "german" :
				link += "lang=german&amp;";
				break;
			case "polish" :
				link += "lang=polish&amp;";
				break;
			case "english" :
				link += "lang=english&amp;";
				break;
			case "spanish" :
				link += "lang=spanish&amp;";
				break;
			case "dutch" :
				link += "lang=dutch&amp;";
				break;
			case "balkan" :
				link += "lang=bosnian&amp;";
				break;
			case "french" :
				link += "lang=french&amp;";
				break;
			case "portugues" :
				link += "lang=portuguese&amp;";
				break;
			case "italian" :
				link += "lang=italian&amp;";
				break;
			case "turkish" :
				link += "lang=turkish&amp;";
				break;
			case "danish" :
				link += "lang=danish&amp;";
				break;
			case "brazilian" :
				link += "lang=brazilian&amp;";
				break;
			case "russian" :
				link += "lang=russian&amp;";
				break;
			case "swedish" :
				link += "lang=swedish&amp;";
				break;
			case "greek" :
				link += "lang=greek&amp;";
				break;
			case "romanian" :
				link += "lang=romanian&amp;";
				break;
			case "hungarian" :
				link += "lang=hungarian&amp;";
				break;
			case "czech" :
				link += "lang=czech&amp;";
				break;
			case "korean" :
				link += "lang=korean&amp;";
				break;
			case "norwegian" :
				// nothing yet
				break;
			case "taiwan" :
				link += "lang=taiwanese&amp;";
				break;
			case "japan" :
				// nothing yet
				break;
			case "chinese" :
				// nothing yet
				break;
			case "bulgarian" :
				link += "lang=bulgarian&amp;";
				break;
			case "lithuanian" :
				// nothing yet
				break;
			case "latvian" :
				// not available yet
				break;
			case "finnish" :
				// not available yet
				break;
			case "slovak" :
				link += "lang=slovak&amp;";
				break;
			case "croatian" :
				link += "lang=bosnian&amp;";
				break;
			case "serbian" :
				// not available yet
				break;
			case "slovenian" :
				// not available yet
				break;
			default:
				link += "lang=english&amp;";
				break;
		}
					
		return link;
	},
	
	update_dragosim_link : function(link, key, value, defend, fleet_no) {
		if (link == "") {
			console.log("invalid method call - empty link provided");
			return false;
		}
	
		var defend   = (defend == true) ? 1 : 0;
		var fleet_no = parseInt(fleet_no);
		
		switch (key) {
			case "coordinates": link += "v_coords="+value+"&amp;"; break;
			case "enemy_name":  link += "v_planet="+value+"&amp;"; break;
	
			case "metal":      link += "v_met="+value+"&amp;"; break;
			case "crystal":    link += "v_kris="+value+"&amp;"; break;
			case "deuterium":  link += "v_deut="+value+"&amp;"; break;
	
			case "kt":         link += "numunits["+defend+"]["+fleet_no+"][k_t]="+value+"&amp;"; break;
			case "gt":         link += "numunits["+defend+"]["+fleet_no+"][g_t]="+value+"&amp;"; break;
			case "lj":         link += "numunits["+defend+"]["+fleet_no+"][l_j]="+value+"&amp;"; break;
			case "sj":         link += "numunits["+defend+"]["+fleet_no+"][s_j]="+value+"&amp;"; break;
			case "krz":        link += "numunits["+defend+"]["+fleet_no+"][kr]="+value+"&amp;"; break;
			case "ss":         link += "numunits["+defend+"]["+fleet_no+"][sc]="+value+"&amp;"; break;
			case "kolo":       link += "numunits["+defend+"]["+fleet_no+"][ko]="+value+"&amp;"; break;
			case "rec":        link += "numunits["+defend+"]["+fleet_no+"][re]="+value+"&amp;"; break;
			case "spio":       link += "numunits["+defend+"]["+fleet_no+"][sp]="+value+"&amp;"; break;
			case "bomb":       link += "numunits["+defend+"]["+fleet_no+"][bo]="+value+"&amp;"; break;
			case "sat":        link += "numunits["+defend+"]["+fleet_no+"][so]="+value+"&amp;"; break;
			case "zerri":      link += "numunits["+defend+"]["+fleet_no+"][z]="+value+"&amp;"; break;
			case "ds": 		   link += "numunits["+defend+"]["+fleet_no+"][t]="+value+"&amp;"; break;
			case "skrz": 	   link += "numunits["+defend+"]["+fleet_no+"][sk]="+value+"&amp;"; break;
	
			case "rak": 	   link += "numunits["+defend+"]["+fleet_no+"][ra]="+value+"&amp;"; break;
			case "ll": 		   link += "numunits["+defend+"]["+fleet_no+"][l_l]="+value+"&amp;"; break;
			case "sl": 		   link += "numunits["+defend+"]["+fleet_no+"][s_l]="+value+"&amp;"; break;
			case "gauss": 	   link += "numunits["+defend+"]["+fleet_no+"][g]="+value+"&amp;"; break;
			case "ion": 	   link += "numunits["+defend+"]["+fleet_no+"][i]="+value+"&amp;"; break;
			case "plasma": 	   link += "numunits["+defend+"]["+fleet_no+"][p]="+value+"&amp;"; break;
			case "ksk": 	   link += "numunits["+defend+"]["+fleet_no+"][k_s]="+value+"&amp;"; break;
			case "gsk": 	   link += "numunits["+defend+"]["+fleet_no+"][g_s]="+value+"&amp;"; break;
	
			case "waffentech": link += "techs[1][0][w_t]="+value+"&amp;"; break;
			case "schildtech": link += "techs[1][0][s_t]="+value+"&amp;"; break;
			case "rpz": 	   link += "techs[1][0][r_p]="+value+"&amp;"; break;
	
			case "arak":       link += "missiles_available_v="+value+"&amp;"; break;
			case "irak":       link += "missiles_available_a="+value+"&amp;"; break;
		}
		
		return link;
	},
	
	get_storage_capacity : function(size) {
		return Math.floor(2.5 * Math.pow(Math.E,(20 * size / 33))) * 5000 ; //Math.floor(2.5 * (Math.pow(Math.E, size))) * 5000;
	},
	
	get_cargo_capacity : function(ship_key) {
		switch (ship_key) {
		case "kt":         return 5000;
		case "gt":         return 25000;
		case "lj":         return 50;
		case "sj":         return 100;
		case "krz":        return 800;
		case "ss":         return 1500;
		case "kolo":       return 7500;
		case "rec":        return 20000;
		case "spio":       return 0;
		case "bomb":       return 500;
		case "zerri":      return 2000;
		case "ds": 		   return 1000000;
		case "skrz": 	   return 750;
		
		default: alert("unknown ship key");
		}
		
	},
	

	CloseReportTooltipIfNotUsed: function () {
		if (galaxytool.report_display.GalaxytoolReportTooltipMouseOver == false) {
			dijit.popup.close(dijit.byId("reporttooltip"));
		}
	},

	CloseReportTooltip: function () {
		dijit.popup.close(dijit.byId("reporttooltip"));
		galaxytool.report_display.GalaxytoolReportTooltipMouseOver = false;
	},
	
	ReportTooltipMouseOver : function() {
		galaxytool.report_display.GalaxytoolReportTooltipMouseOver = true;
	},
	
	ReportTooltipMouseLeave : function() {
		galaxytool.report_display.GalaxytoolReportTooltipMouseOver = false;
	}
};